package com.heima.wemedia.controller.v1;

import com.heima.model.admin.dto.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {

    @Autowired
    private ChannelService channelService;

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult channelDeleteC(@PathVariable("id") Integer id) {

        return channelService.channelDelete(id);
    }

    /**
     * 分页模糊查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult pageFindC(@RequestBody ChannelDto dto) {
        return channelService.pageFind(dto);
    }

    /**
     * 新增保存
     *
     * @param wmChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult channelSaveC(@RequestBody WmChannel wmChannel) {
        return channelService.channelSave(wmChannel);
    }

    @PostMapping("/update")
    public ResponseResult channelUpdateC(@RequestBody WmChannel wmChannel) {
        return channelService.channelUpdate(wmChannel);
    }
}
